package top.malaoshi.ctrl;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.malaoshi.entity.Goods;
import top.malaoshi.model.Result;
import top.malaoshi.service.GoodsSrvImpl;

import javax.annotation.Resource;


@RestController
@RequestMapping("/goods/")
public class GoodsCtrl {

    @Resource
    private GoodsSrvImpl srv;

    @RequestMapping("/showById")
//    public Result queryById(){
    public Result showById(String id){
        Result<Goods> res=new Result<>();
        if(id==null || "".equals(id)){
            res.setCode(100);
            res.setMsg("请输入要查询的ID！");
            return res;
        }
        Goods goods=srv.showById(id);
        res.setCode(0);
        res.setData(goods);
        return res;
    }
}